package com.white.skindemo;

import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;

import com.google.gson.Gson;

import skin.support.SkinCompatManager;
import skin.support.utils.SkinPreference;

public class MainActivity extends AppCompatActivity
{

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if(ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
                PackageManager.PERMISSION_GRANTED)
        {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
        }
    }

    public void click(View view)
    {
        if(TextUtils.isEmpty(SkinPreference.getInstance().getSkinName()))
        {
            SkinCompatManager.getInstance().loadSkin("night.skin", null, SkinCompatManager.SKIN_LOADER_STRATEGY_ASSETS);
        }else
        {
            SkinCompatManager.getInstance().restoreDefaultTheme();
        }
        String json = "{\"ss\":123,\"yy\":11}";
        X x = new Gson().fromJson(json, X.class);
        Log.e("s", String.valueOf(x.ss));
    }

    class X
    {
        int ss;
    }
}
